package com.qdxwx.data.service.notice;

import com.qdxwx.common.page.PageRequest;
import com.qdxwx.common.utils.TKConvert;
import com.qdxwx.data.mapper.notice.NoticeMapper;
import com.qdxwx.models.notice.Notice;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.time.LocalDateTime;
import java.util.List;


/**
 * 公告 服务层实现
 * Qdx NetSchool Platform
 * @author qdxwx
 * @updateTime 2022/5/25
 * @description
 */
@Service
public class NoticeServiceImpl implements NoticeService
{
    @Autowired
    private NoticeMapper noticeMapper;

    @Override
    public Notice get(Long noticeId)
    {
        return noticeMapper.selectNoticeById(noticeId);
    }


    @Override
    public List<Notice> getList(Notice notice, PageRequest page)
    {
        return noticeMapper.selectList(notice,page);
    }

    @Override
    public long count(Notice notice) {
        return noticeMapper.selectCount(notice);
    }


    @Override
    public int insert(Notice notice)
    {
        notice.setCreateTime(LocalDateTime.now());
        return noticeMapper.insertNotice(notice);
    }


    @Override
    public int update(Notice notice)
    {
        notice.setUpdateTime(LocalDateTime.now());
        return noticeMapper.updateNotice(notice);
    }


    @Override
    public int deleteByIds(String ids)
    {
        return noticeMapper.deleteNoticeByIds(TKConvert.toStrArray(ids));
    }
}
